SC comand fails with "[SC] OpenService FAILED 5:"

您所在的位置:网站首页 win10 openscmanager failed SC comand fails with "[SC] OpenService FAILED 5:"

SC comand fails with "[SC] OpenService FAILED 5:"

2023-06-13 20:33| 来源: 网络整理| 查看: 265

Good Morning.

I have a legacy deployment script that uses the sc command to stop a service, make some changes and then start the service.

It's very simple:

sc  stop  sc  query  ...do some stuff... sc  start sc  query 

This deployment script has worked for years on a 2008R2 server. We are now switching to a 2012R2 server. Our provider has given us the new servers and we are building it out.

On some of the servers the script works fine. On other servers it fails.

After digging into the script I found it was failing on the sc start and sc stop commands (an example of the failure is below

C:\>sc stop  [SC] OpenService FAILED 5:

Access is denied.

C:\>echo %ERRORLEVEL% 5

C:\>

The way that we execute the scripts is by simple double click from the windows explorer. The script runs under the permissions of the logged in user.

I know that I can open a command prompt as administrator and then execute the script and it works fine. However, that workaround isn't acceptable. We need to figure out what configuration value or setting on some of these servers is causing this failure.

As indicated earlier, on some of our machines it works fine running as the user and on other machines it fails. What sort of permissions should we be checking for this? The provider doesn't seem to know, they say the machines were deployed the same -- and yet we get different behavior on the two machines.

I'm suspecting that there is some sort of user permission difference (which is not managed by the provider, but a different IT group). I need to get more information to share with them, or better yet, be able to look at server A and see the permission setting, and then server B and see the missing setting and share that with them.

Thanks in advance!

John



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3